import 'package:flutter_smart_heating/service/auth_service.dart';
import 'package:flutter_smart_heating/ui/ui.dart';
import 'package:flutter/material.dart';

class HomeSearchView extends StatelessWidget {
  const HomeSearchView({
    super.key,
  });
  String get placeholder {
    var user = AuthService.instance.user;
    if (user.isSubstation == false && user.substationId! > 0) {
      return '在${user.substationName}中搜索';
    }
    return '搜索';
  }

  @override
  Widget build(BuildContext context) {
    return UiOpen(
      url: '/search?form=index',
      child: UiPanel(
        height: 35,
        backgroundColor: UiTheme.of(context).match(
          light: Colors.white.withOpacity(0.95),
        ),
        child: Row(
          children: [
            const SizedBox(width: 10),
            UiIcon(
              UiIcons.search_short,
              size: 18,
              color: UiTheme(context)
                  .matchColor(Colors.black, Colors.white)
                  .withOpacity(0.4),
            ),
            const SizedBox(width: 5),
            Expanded(
              child: Text(
                placeholder,
                style: TextStyle(
                  fontSize: 14,
                  fontWeight: FontWeight.normal,
                  color: UiTheme(context)
                      .matchColor(Colors.black, Colors.white)
                      .withOpacity(0.4),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
